pp108 : collapse Method

collapse Method


This method collapses the root node or the selected node of the tree by one level.

Syntax

treeID.root.collapse()

When called from a node other than root, the syntax is as follows:

treeNode.collapse()

Return Value


No return value.

Remarks


The operation should be performed only on a parent tree node item that is already expanded (item with a "-" symbol before it indicating that it can be collapsed).

When this function is called, the node is collapsed, and any function associated with the oncollapse property of the tree item is fired. Once collapsed, the tree item will have a "+" symbol in place of "-" indicating that it is already collapsed.

The function will be called internally, when a node is removed from the tree.

The collapse method will be automatically called, and the function associated with oncollapse property will also be fired when a tree node is double-clicked in its expanded state.

Example


The following example shows how the method is used.

//Function called to collapse a tree node on click of a shortcut menu item
function contextCollapseClicked()
{
    //Get the shortcut menu item
    var contextedNode = window.event.activeElement.getTreeItem();

    //Collapse the node
    contextedNode.collapse();
}

See Also


tree, oncollapse